<?php include_once($_SERVER['DOCUMENT_ROOT']."/controller/common/common_setting_unit.php");         // 引入通用的设置文件 ?>
<?php include_once($_SERVER['DOCUMENT_ROOT']."/controller/common/module/head.php"); // 引入通用的头部 ?>
<?php include_once("../controller/order-pepare-statistic.php");                     // 当前页面的控制器 ?>


<?php
header("Cache-Control:public");
header("Pragma:public");

header( "Content-Type: application/vnd.ms-excel; name='excel'" );//表示输出的类型为excel文件类型
header( "Content-type: application/octet-stream" );//表示二进制数据流，常用于文件下载
header( "Content-Disposition: attachment; filename=".$_REQUEST['school'].$_REQUEST['greaterequal_ondate']."至".$_REQUEST['lessequal_ondate'].".xls");//弹框下载文件


//以下三行代码使浏览器每次打开这个页面的时候不会使用缓存从而下载上一个文件
header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
header( "Pragma: no-cache" );
header( "Expires: 0" );
?>

<style>
    tr{border: 1px solid black}
</style>



            <table class="layui-table">
                <colgroup>
                    <col width="80">
                    <col width="150">
                    <col >
                    <col >
                </colgroup>
                <thead>
                <tr>
                    <th>序号</th>
                    <th>日期</th>
                    <th>星期</th>
                    <?foreach ($product_list as $k=>$v){?>
                        <th><?echo $v['product_name']?></th>
                        <?;}?>
                </tr>
                </thead>
                <tbody>
                <? $n=0;?>
                <? for($i=strtotime($_REQUEST['greaterequal_ondate']);$i<=strtotime($_REQUEST['lessequal_ondate']);$i+=86400){?>
                    <? $n++?>
                    <tr>
                        <td><?echo $n?></td>
                        <td><?echo $indate=date("Y-m-d",$i)?></td>
                        <td><?//输出星期几
                            if(date("w",$i)==0){
                                echo "星期日";
                            }
                            elseif(date("w",$i)==1){
                                echo "星期一";
                            }
                            elseif(date("w",$i)==2){
                                echo "星期二";
                            }
                            elseif(date("w",$i)==3){
                                echo "星期三";
                            }
                            elseif(date("w",$i)==4){
                                echo "星期四";
                            }
                            elseif(date("w",$i)==5){
                                echo "星期五";
                            }
                            elseif(date("w",$i)==6){
                                echo "星期六";
                            }

                            ?>

                        </td>


                        <?foreach ($product_list as $k=>$v){?>

                            <td>
                                <?
                                //如果$indate是周六周日的话,就不统计了
                                if(date("w",$i)==0 || date("w",$i)==6){
                                    echo "0";
                                }
                                else{
                                    //统计当天该产品的数量
                                    echo $product_sum[$v['product_name']][]=count_by_item($table_prefix."order_detail",
                                        "status = '正常' and ondate = '{$indate} 00:00:00' and product_name ='{$v['product_name']}'")
                                    ;}
                                ?>
                            </td>
                            <?;}?>




                    </tr>
                <?}?>
                <tr>
                    <td></td>
                    <td></td>
                    <td>合计</td>
                    <?foreach ($product_list as $k=>$v){?>

                        <td>
                            <?echo array_sum($product_sum[$v['product_name']])?>

                        </td>
                        <?;}?>

                </tr>


                </tbody>
            </table>

</html>
